<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <title>基础设置 - 数据字典</title>
    <link rel="stylesheet" href="../stylesheets/common.css" />
    <link rel="stylesheet" href="../stylesheets/table.css" />
    <link rel="stylesheet" href="../fonts/iconfont.css" />
    <style>

    </style>
</head>

<body>
    <div class="place">
        <span class="label-span">位置：</span>
        <span></span>
    </div>
    <div class="body-warp clearfix">
        <table class="table" id="table"></table>
    </div>
    <script type="text/javascript" src="../ext/jquery/jquery-1.11.3.min.js"></script>
    <script type="text/javascript" src="../ext/jquery/selectbox.js"></script>
    <script type="text/javascript" src="../ext/layer/layer.min.js"></script>
    <script type="text/javascript" src="../ext/zw/wzc_grid.js"></script>
    <script type="text/javascript" src="../ext/zw/src/jquery-epaging.js"></script>
    <script type="text/javascript" src="../javascripts/tool-1.1.js"></script>
    <script type="text/javascript" src="../ext/zTree/js/jquery.ztree.core-3.5.min.js"></script>
    <script type="text/javascript" src="../ext/layer_v2/layer.js"></script>
    <link rel="stylesheet" href="../ext/zTree/css/zTreeStyle/zTree.css" type="text/css">
    <script type="text/javascript" src="../ext/zw/lui/common.js"></script>
    <script type="text/javascript" src="../ext/zw/lui/luicontroller.js"></script>
    <script type="text/javascript" src="../ext/zw/lui/droplist.js"></script>
    <script type="text/javascript" src="../ext/zw/lui/panelview.js"></script>
    <script type="text/javascript" src="../ext/jquery/jquery.nicescroll.min.js"></script>
    <script>
    $(function() {
        var grid1 = $('#table').grid({
            store: {
                "data": {
                    "s": 1,
                    "d": [{
                        "_id": "0",
                        "password": "7c4a8d09ca3762af61e59520943dc26494f8941b",
                        "__v": 0,
                        "role": 2,
                        "account": "admin",
                        "name": "年级生",
                        "unit": "grade",
                        "sex": "小学生,初中生,高中生,大学生,研究生,博士",
                        "phone": "2012051224",
                        "type": 'teacher'
                    }, {
                        "_id": "1",
                        "password": "7c4a8d09ca3762af61e59520943dc26494f8941b",
                        "__v": 0,
                        "role": 2,
                        "account": "admin",
                        "name": "性别",
                        "unit": "sex",
                        "sex": "男,女,未知",
                        "phone": "2012120214",
                        "type": 'student'

                    }, {
                        "_id": "2",
                        "password":

                            "7c4a8d09ca3762af61e59520943dc26494f8941b",
                        "__v": 0,
                        "role": 2,
                        "account": "admin",
                        "name": '参赛组',
                        "unit": "group",
                        "sex": "视频组,音频组,动画组,平面组",
                        "phone": "2012120718",
                        "type": 'family'

                    }]
                }
            },
            tool: {
                pagingBar: true,
                checkboxSelect: false,
                "childAjax": 'test.json'

            },
            columns: [{
                title: '字典名称',
                dataIndex: 'name',
                renderer: insertTable
                    /*  这个函数放在了页面的最下面       228
                     *  需要配置的  1.url                233
                     *              2.插入表格的配置     268
                     */
            }, {
                title: '字典值',
                dataIndex: 'unit',
            }, {
                title: '项目列表',
                dataIndex: 'sex'
            }, {
                title: '是否系统值',
                dataIndex: 'role'
            }]

        })




        function insertTable(cellData, rowData, grid, cellIndex, rowIndex) {


            // ajax文件路径  







            var sdl = 'style="font-size:12px;font-weight:bold; color:#508cf9; float:left;" class="insertBtn iconfont icon-plus"'
            var div = $('<div>' + cellData + '</div>');
            var a = $('<i ' + sdl + '></i>');
            div.prepend(a);
            var _oTd = a.parent();
            _oTd.on('click', function() {
                var m = $(this).find('i')
                var _columns = grid.me.opts.columns.length
                url = grid.config.tool.childAjax + '?type=' + rowData.type
                if (m.hasClass('icon-plus')) {
                    m.removeClass('icon-plus').addClass('icon-jian').parent().parent().parent().after('<tr _id="' + rowIndex + '"><td colspan="' + _columns + '" ></td></tr>')
                    $('tr[_id=' + rowIndex + '] td').append('<table id=table' + rowIndex + ' class="table2">')
                    $.post(url, function(data) {
                        if (data.s == -1) {
                            $('#table' + rowIndex + '').append('<p>没有数据</p>')
                        } else {
                            $('#table' + rowIndex + '').grid({
                                store: {
                                    data: data
                                },
                                tool: {
                                    checkboxSelect: false,
                                    removeTableHead: true
                                },
                                columns: [{
                                    dataIndex: 'name'
                                },{
                                    dataIndex: 'name'
                                },{
                                    dataIndex: 'name'
                                },{
                                    dataIndex: 'name'
                                },{
                                    dataIndex: 'name'
                                },{
                                    dataIndex: 'name'
                                },{
                                    dataIndex: 'name'
                                }]
                            })
                        }
                    }, "json");
                } else {
                    m.removeClass('icon-jian').addClass('icon-plus')
                    $('tr[_id=' + rowIndex + ']').remove()
                }
            })
            return div
        }
    })
    </script>
</body>

</html>
